package com.wjq.pay.config;

import java.util.ArrayList;
import java.util.Collections;

public class Singlemode {

    public static void main(String[] args) {

    }

    /**
     * 懒汉式（安全）
     */
    public static class Hungry{
        private Hungry(){}

        private static Hungry hungry=null;

        public static Hungry getInstance(){
            synchronized (Hungry.class){
                if(hungry!=null){
                    return hungry;
                }
            }
            return new Hungry();
        }
    }

    /**
     *饿汉式
     */
    public static class Lazy{
        private Lazy(){}

        private static Lazy lazy=new Lazy();

        public static Lazy getInstance(){

            return lazy;
        }
    }
}
